package com.heima.feign.clients;

import com.heima.schedule.dto.Task;
import com.heima.common.dtos.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * scheduleService对外暴露接口
 */
@FeignClient(value = "leadnews-schedule")
@Transactional
public interface ScheduleClient {

    /**
     * 添加任务
     *
     * @param task
     * @return
     */
    @PostMapping("/api/v1/task/add")
    ResponseResult saveTask(@RequestBody Task task);


    /**
     * 取消任务
     * @param taskId
     * @return
     */
    @GetMapping("/api/v1/task/cancel/{taskId}")
    ResponseResult cancelTask(@PathVariable("taskId") Long taskId);

    /**
     * 根据任务类型和优先级拉取任务
     *
     * @param type
     * @param priority
     * @return
     */
    @GetMapping("/api/v1/task/pull/{type}/{priority}")
    ResponseResult pullTask(@PathVariable("type") int type, @PathVariable("priority") int priority);
}
